Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

261
Visualizações
How to remove the "T" value in datetime-local input type?

I am using datetime-local input type in HTML, but I don't want to use the "T" on the output. I want to only get the date and time with a space between.

<input type="datetime-local" id="date" name="date">

The output is:

2021-11-08T16:34

What i want is:

2021-11-08 16:34

What do i need to do to get this output?

PS: Try to help me without bootstrap libraries, because on this project i can't use it.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

As Dima Parzhitsky wrote, consider to use Intl.DateTimeFormat methods

const
  localDt =_=>
    {
    let now = new Date()
    now.setMinutes(now.getMinutes() - now.getTimezoneOffset())
    now.setSeconds(0)       // remove seconds
    now.setMilliseconds(0) // remove milliseconds
    return now
    }
, fxDate = 
    Intl.DateTimeFormat( undefined,
    { hour12: false, year: 'numeric', month: '2-digit'
    , day: '2-digit', hour: '2-digit', minute: '2-digit'
    })
, dtForm = d => 
    {
    let {day,month,year,hour,minute} = 
      fxDate.formatToParts(d).reduce((o,{type,value})=>(o[type]=value,o),{})
    return `${year}-${month}-${day} ${hour}:${minute}`
    }


dateInput.valueAsDate = localDt()  // init date value 

getDate.onclick =_=>
  {
  let dt = dateInput.valueAsDate
  dt.setMinutes(dt.getMinutes() + dt.getTimezoneOffset())

  dateStr.textContent = dtForm(dt) 
  }
<input type="datetime-local" id="dateInput">
<br><br>
<button id="getDate">get Date</button>


<p id="dateStr">???</p>

about 4 years ago · Juan Pablo Isaza Relatório

0

You can try this, I use pure javascript

//get the date
  var x = document.getElementById("date").value;

//this replaces the 'T' with an space
  x = x.replace("T", " ");

//this places the string back on the HTML page
  document.getElementById("demo").innerHTML = x;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda